package com.dt76.smallloanbackendservice.service.huxuan.impl;

import com.dt76.smallloanbackendservice.service.huxuan.SenderService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Component
public class SenderServiceImpl  implements SenderService {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @Override
    public void sendEmail(int id, String email) {
        System.out.println("发布者id:"+id+"email:"+email);
        HashMap<String , Object> map = new HashMap<>();
        map.put("id",id);
        map.put("email",email);
        this.rabbitTemplate.convertAndSend("email",map);

    }

    @Override
    public void sendSMS(int id, String num) {
        System.out.println("发布者id:"+id+"电话号码:"+num);
        HashMap<String , Object> map = new HashMap<>();
        map.put("id",id);
        map.put("num",num);
        this.rabbitTemplate.convertAndSend("sms",map);
    }
}
